home *** CD-ROM | disk | FTP | other *** search
/ Aminet 21 / Aminet 21 (1997)(GTI - Schatztruhe)[!][Oct 1997].iso / Aminet / gfx / show / gs_src_gs.lha / gs5.03 / scfx.h < prev    next >
C/C++ Source or Header  |  1997-03-21  |  5KB  |  123 lines

  1. /* Copyright (C) 1993, 1995, 1996, 1997 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of Aladdin Ghostscript.
  4.   
  5.   Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author
  6.   or distributor accepts any responsibility for the consequences of using it,
  7.   or for whether it serves any particular purpose or works at all, unless he
  8.   or she says so in writing.  Refer to the Aladdin Ghostscript Free Public
  9.   License (the "License") for full details.
  10.   
  11.   Every copy of Aladdin Ghostscript must include a copy of the License,
  12.   normally in a plain ASCII text file named PUBLIC.  The License grants you
  13.   the right to copy, modify and redistribute Aladdin Ghostscript, but only
  14.   under certain conditions described in the License.  Among other things, the
  15.   License requires that the copyright notice and this notice be preserved on
  16.   all copies.
  17. */
  18.  
  19. /* scfx.h */
  20. /* CCITTFax filter state definition */
  21. /* Requires strimpl.h */
  22. #include "shc.h"
  23.  
  24. /* Common state */
  25. #define stream_CF_state_common\
  26.     stream_hc_state_common;\
  27.         /* The client sets the following before initialization. */\
  28.     bool Uncompressed;\
  29.     int K;\
  30.     bool EndOfLine;\
  31.     bool EncodedByteAlign;\
  32.     int Columns;\
  33.     int Rows;\
  34.     bool EndOfBlock;\
  35.     bool BlackIs1;\
  36.     int DamagedRowsBeforeError;    /* (Decode only) */\
  37.     /*bool FirstBitLowOrder;*/    /* in stream_hc_state_common */\
  38.     int DecodedByteAlign;\
  39.         /* The init procedure sets the following. */\
  40.     uint raster;\
  41.     byte *lbuf;        /* current scan line buffer */\
  42.                 /* (only if decoding or 2-D encoding) */\
  43.     byte *lprev;        /* previous scan line buffer (only if 2-D) */\
  44.         /* The following are updated dynamically. */\
  45.     int k_left;        /* number of next rows to encode in 2-D */\
  46.                 /* (only if K > 0) */\
  47.     int run_color;        /* -1 if processing white run, */\
  48.                 /* 0 if between runs but white is next, */\
  49.                 /* 1 if between runs and black is next, */\
  50.                 /* 2 if processing black run */\
  51.     int damaged_rows;    /* # of consecutive damaged rows preceding */\
  52.                 /* the current row */\
  53.     bool skipping_damage    /* true if skipping a damaged row looking */\
  54.                 /* for EOL */
  55. typedef struct stream_CF_state_s {
  56.     stream_CF_state_common;
  57. } stream_CF_state;
  58. /* Define common default parameter setting. */
  59. #define s_CF_set_defaults_inline(ss)\
  60.   ((ss)->Uncompressed = false,\
  61.    (ss)->K = 0,\
  62.    (ss)->EndOfLine = false,\
  63.    (ss)->EncodedByteAlign = false,\
  64.    (ss)->Columns = 1728,\
  65.    (ss)->Rows = 0,\
  66.    (ss)->EndOfBlock = true,\
  67.    (ss)->BlackIs1 = false,\
  68.         /* Added by Adobe since the Red Book */\
  69.    (ss)->DamagedRowsBeforeError = 0,\
  70.    (ss)->FirstBitLowOrder = false,\
  71.         /* Added by us */\
  72.    (ss)->DecodedByteAlign = 1)
  73.  
  74. /* CCITTFaxEncode */
  75. typedef struct stream_CFE_state_s {
  76.     stream_CF_state_common;
  77.         /* The init procedure sets the following. */
  78.     int max_line_bytes;    /* max # of bytes for a 1-run line */
  79.     int max_run2_bytes;    /* max # of bytes for 2 runs */
  80.     int max_run3_bytes;    /* max # of bytes for 3 runs */
  81.         /* The following change dynamically. */
  82.     int count;        /* # of source bits left to scan, */
  83.                 /* padded to a byte boundary */
  84.     int run_count;        /* count at start of run begin scanned */
  85.     int copy_count;        /* # of bytes to copy into lbuf */
  86.     bool new_line;        /* false if processing a line, */
  87.                 /* true if need to start new line */
  88. } stream_CFE_state;
  89. #define private_st_CFE_state()    /* in scfe.c */\
  90.   gs_private_st_ptrs2(st_CFE_state, stream_CFE_state, "CCITTFaxEncode state",\
  91.     cfe_enum_ptrs, cfe_reloc_ptrs, lbuf, lprev)
  92. #define s_CFE_set_defaults_inline(ss)\
  93.   s_CF_set_defaults_inline(ss)
  94. extern const stream_template s_CFE_template;
  95.  
  96. /* CCITTFaxDecode */
  97. typedef struct stream_CFD_state_s {
  98.     stream_CF_state_common;
  99.     int cbit;        /* bits left to fill in current decoded */
  100.                 /* byte at lbuf[wpos] (0..7) */
  101.     int rows_left;        /* number of rows left */
  102.     int rpos;        /* rptr for copying lbuf to client */
  103.     int wpos;        /* rlimit/wptr for filling lbuf or */
  104.                 /* copying to client */
  105.     int eol_count;        /* number of EOLs seen so far */
  106.     byte invert;        /* current value of 'white' */
  107.                 /* for 2-D decoding */
  108.     /* The following are not used yet. */
  109.     int uncomp_run;        /* non-0 iff we are in an uncompressed */
  110.                 /* run straddling a scan line (-1 if white, */
  111.                 /* 1 if black) */
  112.     int uncomp_left;    /* # of bits left in the run */
  113.     int uncomp_exit;    /* non-0 iff this is an exit run */
  114.                 /* (-1 if next run white, 1 if black) */
  115. } stream_CFD_state;
  116. #define private_st_CFD_state()    /* in scfd.c */\
  117.   gs_private_st_ptrs2(st_CFD_state, stream_CFD_state, "CCITTFaxDecode state",\
  118.     cfd_enum_ptrs, cfd_reloc_ptrs, lbuf, lprev)
  119. #define s_CFD_set_defaults_inline(ss)\
  120.   (s_CF_set_defaults_inline(ss),\
  121.    (ss)->DamagedRowsBeforeError = 0)
  122. extern const stream_template s_CFD_template;
  123.